package com.ruoyi.cbs.sign.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cbs.sign.domain.SignImage;
import com.ruoyi.cbs.sign.service.ISignImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员签字模板Controller
 * 
 * @author ruoyi
 * @date 2025-11-21
 */
@RestController
@RequestMapping("/sign/signImg")
public class SignImageController extends BaseController
{
    @Autowired
    private ISignImageService signImageService;

    /**
     * 查询人员签字模板列表
     */
    @PreAuthorize("@ss.hasPermi('sign:signImg:list')")
    @GetMapping("/list")
    public TableDataInfo list(SignImage signImage)
    {
        startPage();
        List<SignImage> list = signImageService.selectSignImageList(signImage);
        return getDataTable(list);
    }

    /**
     * 导出人员签字模板列表
     */
    @PreAuthorize("@ss.hasPermi('sign:signImg:export')")
    @Log(title = "人员签字模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignImage signImage)
    {
        List<SignImage> list = signImageService.selectSignImageList(signImage);
        ExcelUtil<SignImage> util = new ExcelUtil<SignImage>(SignImage.class);
        util.exportExcel(response, list, "人员签字模板数据");
    }

    /**
     * 获取人员签字模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('sign:signImg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(signImageService.selectSignImageById(id));
    }

    /**
     * 新增人员签字模板
     */
    @PreAuthorize("@ss.hasPermi('sign:signImg:add')")
    @Log(title = "人员签字模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignImage signImage)
    {
        return toAjax(signImageService.insertSignImage(signImage));
    }

    /**
     * 修改人员签字模板
     */
    @PreAuthorize("@ss.hasPermi('sign:signImg:edit')")
    @Log(title = "人员签字模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignImage signImage)
    {
        return toAjax(signImageService.updateSignImage(signImage));
    }

    /**
     * 删除人员签字模板
     */
    @PreAuthorize("@ss.hasPermi('sign:signImg:remove')")
    @Log(title = "人员签字模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(signImageService.deleteSignImageByIds(ids));
    }
}
